﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Models
{
    public class Student
    {

         string id;
         string name;
         string className;
         double score1;
         double score2;

        public double Score1
        {
            get => score1; set
            {
                if (score1 >= 0 && score1 <= 100) { score1 = value; }

                else
                {
                    score1 = 0;
                    Console.WriteLine("错误的分数值");
                }

            }
        }
        public double Score2
        {
            get => score2; set
            {
                if (score2 >= 0 && score2 <= 100) { score2 = value; }

                else
                {
                    score2 = 0;
                    Console.WriteLine("错误的分数值");
                }

            }
        }
        public string Id { get => id; set => id = value; }
        public string Name { get => name; set => name = value; }
        public string ClassName { get => className; set => className = value; }

        public double Total()
        {
            return Score1 + Score2;
        }
        public void DispStu()
        {
            Console.WriteLine($"{Id}\n{Name}\n{ClassName}\n{Total()}");
        }

        public Student(string sno,string stuName,double s1,double s2)
        {
            id = sno;
            name = stuName;
            score1 = s1;
            score2 = s2;
        }

        public double Average() 
        {
            return (score1 + score2) / 2;
        }

        public void Output()
        {
            Console.WriteLine($"姓名：{name}\n学号：{id}\n成绩1：{score1}\n成绩2：{score2}\n平均分：{Average()}");
        }
    }
}
